var minSubArrayLen = function (target, nums) {
    let left = 0;
    let right = 0;
    let sum = nums[left];
    let res = nums.length + 1; //子数组最大不超过自身
    if (res == nums.length + 1) {
        res = 0;
    }
    while (left < nums.length && right < nums.length) {
        //找可行解
        if (sum < target) {
            right++;
            sum += nums[end];
        } else {
            if (right - left + 1 <= res) {
                res = right - left + 1;
            }
            sum -= nums[left];
            left++;
        }
    }
    return res;
}